Attribute VB_Name = "basMQ"
Option Explicit
'>>barb
'Public objMqAdoConn As New clsobjadocon
'Public objMqAdoConn As clsAdoConnection
'Public objMqAdoConn As Object
'>>Barb
Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" _
    (ByVal Lpbuffer As String, nsize As Long) As Long

'**********************************************************************'
'*                                                                    *'
'*  Program name:  CMQB5                                              *'
'*                                                                    *'
'*  Description:   This file declares calls, structures, and          *'
'*                 constants for the IBM Message Queue Interface      *'
'*                 (MQI) in the Windows Visual Basic V5.0             *'
'*                 environment.                                       *'
'*                                                                    *'
'*                 CMQB5 will run against either                      *'
'*                    the MQSeries server,                            *'
'*                    the MQSeries client, or                         *'
'*                    or the MQSeries common client/server            *'
'*                         (when available)                           *'
'*                 set by the conditional compiler constant MqType    *'
'*                 MqType may be set for a project using the          *'
'*                   Visual Basic menu 'Project - Project Property...'*'
'*                   under the 'Make' tab.                            *'
'*                   Set the 'Conditional Compilation Argument' to    *'
'*                       "MqType = 1" for the MQSeries server         *'
'*                       "MqType = 2" for the MQSeries client         *'
'*                       "MqType = 3" for the MQSeries common base    *'
'*                                                                    *'
'*  Statement:     Licensed Materials - Property of IBM               *'
'*                 (C) Copyright IBM Corp. 1994, 1997                 *'
'*                                                                    *'
'*                 U.S. Government Users Restricted Rights -          *'
'*                 use, duplication or disclosure restricted by       *'
'*                 GSA ADP Schedule Contract with IBM Corp.           *'
'*                                                                    *'
'**********************************************************************'

'**********************************************************************'
'*  Values Related to MQDLH Structure                                 *'
'**********************************************************************'

'Structure Identifier'
Global Const MQDLH_STRUC_ID = "DLH "

'Structure Version Number'
Global Const MQDLH_VERSION_1 = 1


'**********************************************************************'
'*  Values Related to MQGMO Structure                                 *'
'**********************************************************************'

'Structure Identifier'
Global Const MQGMO_STRUC_ID = "GMO "

'Structure Version Number'
Global Const MQGMO_VERSION_1 = 1

'Get-Message Options'
Global Const MQGMO_WAIT = 1
Global Const MQGMO_NO_WAIT = 0
Global Const MQGMO_SYNCPOINT = 2
Global Const MQGMO_NO_SYNCPOINT = 4
Global Const MQGMO_BROWSE_FIRST = 16
Global Const MQGMO_BROWSE_NEXT = 32
Global Const MQGMO_BROWSE_MSG_UNDER_CURSOR = 2048
Global Const MQGMO_MSG_UNDER_CURSOR = 256
Global Const MQGMO_LOCK = 512
Global Const MQGMO_UNLOCK = 1024
Global Const MQGMO_ACCEPT_TRUNCATED_MSG = 64
Global Const MQGMO_FAIL_IF_QUIESCING = 8192
Global Const MQGMO_CONVERT = 16384
Global Const MQGMO_NONE = 0

'Wait Interval'
Global Const MQWI_UNLIMITED = -1


'**********************************************************************'
'*  Values Related to MQMD Structure                                  *'
'**********************************************************************'

'Structure Identifier'
Global Const MQMD_STRUC_ID = "MD  "

'Structure Version Number'
Global Const MQMD_VERSION_1 = 1

'Report Options'
Global Const MQRO_EXCEPTION = 16777216
Global Const MQRO_EXCEPTION_WITH_DATA = 50331648
Global Const MQRO_EXCEPTION_WITH_FULL_DATA = 117440512
Global Const MQRO_EXPIRATION = 2097152
Global Const MQRO_EXPIRATION_WITH_DATA = 6291456
Global Const MQRO_EXPIRATION_WITH_FULL_DATA = 14680064
Global Const MQRO_COA = 256
Global Const MQRO_COA_WITH_DATA = 768
Global Const MQRO_COA_WITH_FULL_DATA = 1792
Global Const MQRO_COD = 2048
Global Const MQRO_COD_WITH_DATA = 6144
Global Const MQRO_COD_WITH_FULL_DATA = 14336
Global Const MQRO_NEW_MSG_ID = 0
Global Const MQRO_PASS_MSG_ID = 128
Global Const MQRO_COPY_MSG_ID_TO_CORREL_ID = 0
Global Const MQRO_PASS_CORREL_ID = 64
Global Const MQRO_DEAD_LETTER_Q = 0
Global Const MQRO_DISCARD_MSG = 134217728
Global Const MQRO_NONE = 0

'Report Options Masks'
Global Const MQRO_REJECT_UNSUP_MASK = &H101C0000
Global Const MQRO_ACCEPT_UNSUP_MASK = &HEFE000FF
Global Const MQRO_ACCEPT_UNSUP_IF_XMIT_MASK = &H3FF00

'Message Types'
Global Const MQMT_SYSTEM_FIRST = 1
Global Const MQMT_REQUEST = 1
Global Const MQMT_REPLY = 2
Global Const MQMT_DATAGRAM = 8
Global Const MQMT_REPORT = 4
Global Const MQMT_SYSTEM_LAST = 65535
Global Const MQMT_APPL_FIRST = 65536
Global Const MQMT_APPL_LAST = 999999999

'Expiry'
Global Const MQEI_UNLIMITED = -1

'Feedback Values'
Global Const MQFB_NONE = 0
Global Const MQFB_SYSTEM_FIRST = 1
Global Const MQFB_QUIT = 256
Global Const MQFB_EXPIRATION = 258
Global Const MQFB_COA = 259
Global Const MQFB_COD = 260
Global Const MQFB_CHANNEL_COMPLETED = 262
Global Const MQFB_CHANNEL_FAIL_RETRY = 263
Global Const MQFB_CHANNEL_FAIL = 264
Global Const MQFB_APPL_CANNOT_BE_STARTED = 265
Global Const MQFB_TM_ERROR = 266
Global Const MQFB_APPL_TYPE_ERROR = 267
Global Const MQFB_STOPPED_BY_MSG_EXIT = 268
Global Const MQFB_XMIT_Q_MSG_ERROR = 271
Global Const MQFB_SYSTEM_LAST = 65535
Global Const MQFB_APPL_FIRST = 65536
Global Const MQFB_APPL_LAST = 999999999

'Encoding'
Global Const MQENC_NATIVE = 546

'Encoding Masks'
Global Const MQENC_INTEGER_MASK = &HF
Global Const MQENC_DECIMAL_MASK = &HF0
Global Const MQENC_FLOAT_MASK = &HF00
Global Const MQENC_RESERVED_MASK = &HF000

'Encodings for Binary Integers'
Global Const MQENC_INTEGER_UNDEFINED = 0
Global Const MQENC_INTEGER_NORMAL = 1
Global Const MQENC_INTEGER_REVERSED = 2

'Encodings for Packed-Decimal Integers'
Global Const MQENC_DECIMAL_UNDEFINED = 0
Global Const MQENC_DECIMAL_NORMAL = 16
Global Const MQENC_DECIMAL_REVERSED = 32

'Encodings for Floating-Point Numbers'
Global Const MQENC_FLOAT_UNDEFINED = 0
Global Const MQENC_FLOAT_IEEE_NORMAL = 256
Global Const MQENC_FLOAT_IEEE_REVERSED = 512
Global Const MQENC_FLOAT_S390 = 768

'Coded Character-Set Identifiers'
Global Const MQCCSI_DEFAULT = 0
Global Const MQCCSI_Q_MGR = 0
Global Const MQCCSI_EMBEDDED = -1

'Formats'
Global Const MQFMT_NONE = "        "
Global Const MQFMT_ADMIN = "MQADMIN "
Global Const MQFMT_CHANNEL_COMPLETED = "MQCHCOM "
Global Const MQFMT_COMMAND_1 = "MQCMD1  "
Global Const MQFMT_COMMAND_2 = "MQCMD2  "
Global Const MQFMT_DEAD_LETTER_HEADER = "MQDEAD  "
Global Const MQFMT_EVENT = "MQEVENT "
Global Const MQFMT_PCF = "MQPCF   "
Global Const MQFMT_STRING = "MQSTR   "
Global Const MQFMT_TRIGGER = "MQTRIG  "
Global Const MQFMT_XMIT_Q_HEADER = "MQXMIT  "

'Priority'
Global Const MQPRI_PRIORITY_AS_Q_DEF = -1

'Persistence Values'
Global Const MQPER_PERSISTENT = 1
Global Const MQPER_NOT_PERSISTENT = 0
Global Const MQPER_PERSISTENCE_AS_Q_DEF = 2

'Message Id'
Public MQMI_NONE As String * 24 'must initialise with MQSET_DEFAULTS call

'Correlation Id'
Public MQCI_NONE As String * 24 'must initialise with MQSET_DEFAULTS call

'Accounting Token'
Public MQACT_NONE As String * 32 'must initialise with MQSET_DEFAULTS call

'Put Application Types'
Global Const MQAT_UNKNOWN = -1
Global Const MQAT_NO_CONTEXT = 0
Global Const MQAT_CICS = 1
Global Const MQAT_MVS = 2
Global Const MQAT_IMS = 3
Global Const MQAT_OS2 = 4
Global Const MQAT_DOS = 5
Global Const MQAT_AIX = 6
Global Const MQAT_UNIX = 6
Global Const MQAT_QMGR = 7
Global Const MQAT_OS400 = 8
Global Const MQAT_WINDOWS = 9
Global Const MQAT_CICS_VSE = 10
Global Const MQAT_WINDOWS_NT = 11
Global Const MQAT_VMS = 12
Global Const MQAT_GUARDIAN = 13
Global Const MQAT_VOS = 14
Global Const MQAT_DEFAULT = 9
Global Const MQAT_USER_FIRST = 65536
Global Const MQAT_USER_LAST = 999999999


'**********************************************************************'
'*  Values Related to MQOD Structure                                  *'
'**********************************************************************'

'Structure Identifier'
Global Const MQOD_STRUC_ID = "OD  "

'Structure Version Number'
Global Const MQOD_VERSION_1 = 1

'Object Types'
Global Const MQOT_Q = 1
Global Const MQOT_PROCESS = 3
Global Const MQOT_Q_MGR = 5
Global Const MQOT_CHANNEL = 6

'Extended Object Types'
Global Const MQOT_ALL = 1001
Global Const MQOT_ALIAS_Q = 1002
Global Const MQOT_MODEL_Q = 1003
Global Const MQOT_LOCAL_Q = 1004
Global Const MQOT_REMOTE_Q = 1005
Global Const MQOT_SENDER_CHANNEL = 1007
Global Const MQOT_SERVER_CHANNEL = 1008
Global Const MQOT_REQUESTER_CHANNEL = 1009
Global Const MQOT_RECEIVER_CHANNEL = 1010
Global Const MQOT_CURRENT_CHANNEL = 1011
Global Const MQOT_SAVED_CHANNEL = 1012


'**********************************************************************'
'*  Values Related to MQPMO Structure                                 *'
'**********************************************************************'

'Structure Identifier'
Global Const MQPMO_STRUC_ID = "PMO "

'Structure Version Number'
Global Const MQPMO_VERSION_1 = 1

'Put-Message Options'
Global Const MQPMO_SYNCPOINT = 2
Global Const MQPMO_NO_SYNCPOINT = 4
Global Const MQPMO_NO_CONTEXT = 16384
Global Const MQPMO_DEFAULT_CONTEXT = 32
Global Const MQPMO_PASS_IDENTITY_CONTEXT = 256
Global Const MQPMO_PASS_ALL_CONTEXT = 512
Global Const MQPMO_SET_IDENTITY_CONTEXT = 1024
Global Const MQPMO_SET_ALL_CONTEXT = 2048
Global Const MQPMO_ALTERNATE_USER_AUTHORITY = 4096
Global Const MQPMO_FAIL_IF_QUIESCING = 8192
Global Const MQPMO_NONE = 0


'**********************************************************************'
'*  Values Related to MQTM Structure                                  *'
'**********************************************************************'

'Structure Identifier'
Global Const MQTM_STRUC_ID = "TM  "

'Structure Version Number'
Global Const MQTM_VERSION_1 = 1


'**********************************************************************'
'*  Values Related to MQTMC2 Structure                                *'
'**********************************************************************'

'Structure Identifier'
Global Const MQTMC_STRUC_ID = "TMC "

'Structure Version Number'
Global Const MQTMC_VERSION_1 = "   1"
Global Const MQTMC_VERSION_2 = "   2"


'**********************************************************************'
'*  Values Related to MQXQH Structure                                 *'
'**********************************************************************'

'Structure Identifier'
Global Const MQXQH_STRUC_ID = "XQH "

'Structure Version Number'
Global Const MQXQH_VERSION_1 = 1


'**********************************************************************'
'*  Values Related to MQCLOSE Call                                    *'
'**********************************************************************'

'Object Handle'
Global Const MQHO_UNUSABLE_HOBJ = -1

'Close Options'
Global Const MQCO_NONE = 0
Global Const MQCO_DELETE = 1
Global Const MQCO_DELETE_PURGE = 2


'**********************************************************************'
'*  Values Related to MQINQ Call                                      *'
'**********************************************************************'

'Character-Attribute Selectors'
Global Const MQCA_APPL_ID = 2001
Global Const MQCA_BACKOUT_REQ_Q_NAME = 2019
Global Const MQCA_BASE_Q_NAME = 2002
Global Const MQCA_COMMAND_INPUT_Q_NAME = 2003
Global Const MQCA_CREATION_DATE = 2004
Global Const MQCA_CREATION_TIME = 2005
Global Const MQCA_DEAD_LETTER_Q_NAME = 2006
Global Const MQCA_DEF_XMIT_Q_NAME = 2025
Global Const MQCA_ENV_DATA = 2007
Global Const MQCA_FIRST = 2001
Global Const MQCA_INITIATION_Q_NAME = 2008
Global Const MQCA_LAST = 4000
Global Const MQCA_LAST_USED = 2025
Global Const MQCA_NAMES = 2020
Global Const MQCA_PROCESS_DESC = 2011
Global Const MQCA_PROCESS_NAME = 2012
Global Const MQCA_Q_DESC = 2013
Global Const MQCA_Q_MGR_DESC = 2014
Global Const MQCA_Q_MGR_NAME = 2015
Global Const MQCA_Q_NAME = 2016
Global Const MQCA_REMOTE_Q_MGR_NAME = 2017
Global Const MQCA_REMOTE_Q_NAME = 2018
Global Const MQCA_STORAGE_CLASS = 2022
Global Const MQCA_TRIGGER_DATA = 2023
Global Const MQCA_USER_DATA = 2021
Global Const MQCA_XMIT_Q_NAME = 2024

'Integer-Attribute Selectors'
Global Const MQIA_APPL_TYPE = 1
Global Const MQIA_AUTHORITY_EVENT = 47
Global Const MQIA_BACKOUT_THRESHOLD = 22
Global Const MQIA_CODED_CHAR_SET_ID = 2
Global Const MQIA_COMMAND_LEVEL = 31
Global Const MQIA_CURRENT_Q_DEPTH = 3
Global Const MQIA_DEF_INPUT_OPEN_OPTION = 4
Global Const MQIA_DEF_PERSISTENCE = 5
Global Const MQIA_DEF_PRIORITY = 6
Global Const MQIA_DEFINITION_TYPE = 7
Global Const MQIA_FIRST = 1
Global Const MQIA_HARDEN_GET_BACKOUT = 8
Global Const MQIA_HIGH_Q_DEPTH = 36
Global Const MQIA_INHIBIT_EVENT = 48
Global Const MQIA_INHIBIT_GET = 9
Global Const MQIA_INHIBIT_PUT = 10
Global Const MQIA_LAST = 2000
Global Const MQIA_LAST_USED = 54
Global Const MQIA_LOCAL_EVENT = 49
Global Const MQIA_MAX_HANDLES = 11
Global Const MQIA_MAX_MSG_LENGTH = 13
Global Const MQIA_MAX_PRIORITY = 14
Global Const MQIA_MAX_Q_DEPTH = 15
Global Const MQIA_MAX_UNCOMMITTED_MSGS = 33
Global Const MQIA_MSG_DELIVERY_SEQUENCE = 16
Global Const MQIA_MSG_DEQ_COUNT = 38
Global Const MQIA_MSG_ENQ_COUNT = 37
Global Const MQIA_NAME_COUNT = 19
Global Const MQIA_OPEN_INPUT_COUNT = 17
Global Const MQIA_OPEN_OUTPUT_COUNT = 18
Global Const MQIA_PERFORMANCE_EVENT = 53
Global Const MQIA_PLATFORM = 32
Global Const MQIA_Q_DEPTH_HIGH_EVENT = 43
Global Const MQIA_Q_DEPTH_HIGH_LIMIT = 40
Global Const MQIA_Q_DEPTH_LOW_EVENT = 44
Global Const MQIA_Q_DEPTH_LOW_LIMIT = 41
Global Const MQIA_Q_DEPTH_MAX_EVENT = 42
Global Const MQIA_Q_SERVICE_INTERVAL = 54
Global Const MQIA_Q_SERVICE_INTERVAL_EVENT = 46
Global Const MQIA_Q_TYPE = 20
Global Const MQIA_REMOTE_EVENT = 50
Global Const MQIA_RETENTION_INTERVAL = 21
Global Const MQIA_SCOPE = 45
Global Const MQIA_SHAREABILITY = 23
Global Const MQIA_START_STOP_EVENT = 52
Global Const MQIA_SYNCPOINT = 30
Global Const MQIA_TIME_SINCE_RESET = 35
Global Const MQIA_TRIGGER_CONTROL = 24
Global Const MQIA_TRIGGER_DEPTH = 29
Global Const MQIA_TRIGGER_INTERVAL = 25
Global Const MQIA_TRIGGER_MSG_PRIORITY = 26
Global Const MQIA_TRIGGER_TYPE = 28
Global Const MQIA_USAGE = 12

'Integer Attribute Value Denoting "Not Applicable"'
Global Const MQIAV_NOT_APPLICABLE = -1


'**********************************************************************'
'*  Values Related to MQOPEN Call                                     *'
'**********************************************************************'

'Open Options'
Global Const MQOO_INPUT_AS_Q_DEF = 1
Global Const MQOO_INPUT_SHARED = 2
Global Const MQOO_INPUT_EXCLUSIVE = 4
Global Const MQOO_BROWSE = 8
Global Const MQOO_OUTPUT = 16
Global Const MQOO_INQUIRE = 32
Global Const MQOO_SET = 64
Global Const MQOO_SAVE_ALL_CONTEXT = 128
Global Const MQOO_PASS_IDENTITY_CONTEXT = 256
Global Const MQOO_PASS_ALL_CONTEXT = 512
Global Const MQOO_SET_IDENTITY_CONTEXT = 1024
Global Const MQOO_SET_ALL_CONTEXT = 2048
Global Const MQOO_ALTERNATE_USER_AUTHORITY = 4096
Global Const MQOO_FAIL_IF_QUIESCING = 8192


'**********************************************************************'
'*  Values Related to All Calls                                       *'
'**********************************************************************'

'Connection Handle'
Global Const MQHC_UNUSABLE_HCONN = -1

'String Lengths'
Global Const MQ_ACCOUNTING_TOKEN_LENGTH = 32
Global Const MQ_APPL_IDENTITY_DATA_LENGTH = 32
Global Const MQ_APPL_NAME_LENGTH = 28
Global Const MQ_APPL_ORIGIN_DATA_LENGTH = 4
Global Const MQ_CHANNEL_DATE_LENGTH = 12
Global Const MQ_CHANNEL_DESC_LENGTH = 64
Global Const MQ_CHANNEL_NAME_LENGTH = 20
Global Const MQ_CHANNEL_TIME_LENGTH = 8
Global Const MQ_CONN_NAME_LENGTH = 264
Global Const MQ_CORREL_ID_LENGTH = 24
Global Const MQ_CREATION_DATE_LENGTH = 12
Global Const MQ_CREATION_TIME_LENGTH = 8
Global Const MQ_EXIT_DATA_LENGTH = 32
Global Const MQ_EXIT_NAME_LENGTH = 128
Global Const MQ_EXIT_USER_AREA_LENGTH = 16
Global Const MQ_FORMAT_LENGTH = 8
Global Const MQ_LUWID_LENGTH = 16
Global Const MQ_MCA_JOB_NAME_LENGTH = 28
Global Const MQ_MCA_NAME_LENGTH = 20
Global Const MQ_MODE_NAME_LENGTH = 8
Global Const MQ_MSG_HEADER_LENGTH = 4000
Global Const MQ_MSG_ID_LENGTH = 24
Global Const MQ_PASSWORD_LENGTH = 12
Global Const MQ_PROCESS_APPL_ID_LENGTH = 256
Global Const MQ_PROCESS_DESC_LENGTH = 64
Global Const MQ_PROCESS_ENV_DATA_LENGTH = 128
Global Const MQ_PROCESS_NAME_LENGTH = 48
Global Const MQ_PROCESS_USER_DATA_LENGTH = 128
Global Const MQ_PUT_APPL_NAME_LENGTH = 28
Global Const MQ_PUT_DATE_LENGTH = 8
Global Const MQ_PUT_TIME_LENGTH = 8
Global Const MQ_Q_DESC_LENGTH = 64
Global Const MQ_Q_NAME_LENGTH = 48
Global Const MQ_Q_MGR_DESC_LENGTH = 64
Global Const MQ_Q_MGR_NAME_LENGTH = 48
Global Const MQ_SHORT_CONN_NAME_LENGTH = 20
Global Const MQ_STORAGE_CLASS_LENGTH = 8
Global Const MQ_TP_NAME_LENGTH = 64
Global Const MQ_TRIGGER_DATA_LENGTH = 64
Global Const MQ_USER_ID_LENGTH = 12

'Completion Codes'
Global Const MQCC_OK = 0
Global Const MQCC_WARNING = 1
Global Const MQCC_FAILED = 2
Global Const MQCC_UNKNOWN = -1

'Reason Codes'
Global Const MQRC_NONE = 0
Global Const MQRC_ALIAS_BASE_Q_TYPE_ERROR = 2001
Global Const MQRC_ALREADY_CONNECTED = 2002
Global Const MQRC_BACKED_OUT = 2003
Global Const MQRC_BUFFER_ERROR = 2004
Global Const MQRC_BUFFER_LENGTH_ERROR = 2005
Global Const MQRC_CHAR_ATTR_LENGTH_ERROR = 2006
Global Const MQRC_CHAR_ATTRS_ERROR = 2007
Global Const MQRC_CHAR_ATTRS_TOO_SHORT = 2008
Global Const MQRC_CONNECTION_BROKEN = 2009
Global Const MQRC_DATA_LENGTH_ERROR = 2010
Global Const MQRC_DYNAMIC_Q_NAME_ERROR = 2011
Global Const MQRC_ENVIRONMENT_ERROR = 2012
Global Const MQRC_EXPIRY_ERROR = 2013
Global Const MQRC_FEEDBACK_ERROR = 2014
Global Const MQRC_GET_INHIBITED = 2016
Global Const MQRC_HANDLE_NOT_AVAILABLE = 2017
Global Const MQRC_HCONN_ERROR = 2018
Global Const MQRC_HOBJ_ERROR = 2019
Global Const MQRC_INHIBIT_VALUE_ERROR = 2020
Global Const MQRC_INT_ATTR_COUNT_ERROR = 2021
Global Const MQRC_INT_ATTR_COUNT_TOO_SMALL = 2022
Global Const MQRC_INT_ATTRS_ARRAY_ERROR = 2023
Global Const MQRC_SYNCPOINT_LIMIT_REACHED = 2024
Global Const MQRC_MAX_CONNS_LIMIT_REACHED = 2025
Global Const MQRC_MD_ERROR = 2026
Global Const MQRC_MISSING_REPLY_TO_Q = 2027
Global Const MQRC_MSG_TYPE_ERROR = 2029
Global Const MQRC_MSG_TOO_BIG_FOR_Q = 2030
Global Const MQRC_MSG_TOO_BIG_FOR_Q_MGR = 2031
Global Const MQRC_NO_MSG_AVAILABLE = 2033
Global Const MQRC_NO_MSG_UNDER_CURSOR = 2034
Global Const MQRC_NOT_AUTHORIZED = 2035
Global Const MQRC_NOT_OPEN_FOR_BROWSE = 2036
Global Const MQRC_NOT_OPEN_FOR_INPUT = 2037
Global Const MQRC_NOT_OPEN_FOR_INQUIRE = 2038
Global Const MQRC_NOT_OPEN_FOR_OUTPUT = 2039
Global Const MQRC_NOT_OPEN_FOR_SET = 2040
Global Const MQRC_OBJECT_CHANGED = 2041
Global Const MQRC_OBJECT_IN_USE = 2042
Global Const MQRC_OBJECT_TYPE_ERROR = 2043
Global Const MQRC_OD_ERROR = 2044
Global Const MQRC_OPTION_NOT_VALID_FOR_TYPE = 2045
Global Const MQRC_OPTIONS_ERROR = 2046
Global Const MQRC_PERSISTENCE_ERROR = 2047
Global Const MQRC_PERSISTENT_NOT_ALLOWED = 2048
Global Const MQRC_PRIORITY_EXCEEDS_MAXIMUM = 2049
Global Const MQRC_PRIORITY_ERROR = 2050
Global Const MQRC_PUT_INHIBITED = 2051
Global Const MQRC_Q_DELETED = 2052
Global Const MQRC_Q_FULL = 2053
Global Const MQRC_Q_NOT_EMPTY = 2055
Global Const MQRC_Q_SPACE_NOT_AVAILABLE = 2056
Global Const MQRC_Q_TYPE_ERROR = 2057
Global Const MQRC_Q_MGR_NAME_ERROR = 2058
Global Const MQRC_Q_MGR_NOT_AVAILABLE = 2059
Global Const MQRC_REPORT_OPTIONS_ERROR = 2061
Global Const MQRC_SECOND_MARK_NOT_ALLOWED = 2062
Global Const MQRC_SECURITY_ERROR = 2063
Global Const MQRC_SELECTOR_COUNT_ERROR = 2065
Global Const MQRC_SELECTOR_LIMIT_EXCEEDED = 2066
Global Const MQRC_SELECTOR_ERROR = 2067
Global Const MQRC_SELECTOR_NOT_FOR_TYPE = 2068
Global Const MQRC_SIGNAL_OUTSTANDING = 2069
Global Const MQRC_SIGNAL_REQUEST_ACCEPTED = 2070
Global Const MQRC_STORAGE_NOT_AVAILABLE = 2071
Global Const MQRC_SYNCPOINT_NOT_AVAILABLE = 2072
Global Const MQRC_TRIGGER_CONTROL_ERROR = 2075
Global Const MQRC_TRIGGER_DEPTH_ERROR = 2076
Global Const MQRC_TRIGGER_MSG_PRIORITY_ERR = 2077
Global Const MQRC_TRIGGER_TYPE_ERROR = 2078
Global Const MQRC_TRUNCATED_MSG_ACCEPTED = 2079
Global Const MQRC_TRUNCATED_MSG_FAILED = 2080
Global Const MQRC_UNKNOWN_ALIAS_BASE_Q = 2082
Global Const MQRC_UNKNOWN_OBJECT_NAME = 2085
Global Const MQRC_UNKNOWN_OBJECT_Q_MGR = 2086
Global Const MQRC_UNKNOWN_REMOTE_Q_MGR = 2087
Global Const MQRC_WAIT_INTERVAL_ERROR = 2090
Global Const MQRC_XMIT_Q_TYPE_ERROR = 2091
Global Const MQRC_XMIT_Q_USAGE_ERROR = 2092
Global Const MQRC_NOT_OPEN_FOR_PASS_ALL = 2093
Global Const MQRC_NOT_OPEN_FOR_PASS_IDENT = 2094
Global Const MQRC_NOT_OPEN_FOR_SET_ALL = 2095
Global Const MQRC_NOT_OPEN_FOR_SET_IDENT = 2096
Global Const MQRC_CONTEXT_HANDLE_ERROR = 2097
Global Const MQRC_CONTEXT_NOT_AVAILABLE = 2098
Global Const MQRC_SIGNAL1_ERROR = 2099
Global Const MQRC_OBJECT_ALREADY_EXISTS = 2100
Global Const MQRC_OBJECT_DAMAGED = 2101
Global Const MQRC_RESOURCE_PROBLEM = 2102
Global Const MQRC_ANOTHER_Q_MGR_CONNECTED = 2103
Global Const MQRC_UNKNOWN_REPORT_OPTION = 2104
Global Const MQRC_STORAGE_CLASS_ERROR = 2105
Global Const MQRC_COD_NOT_VALID_FOR_XCF_Q = 2106
Global Const MQRC_SUPPRESSED_BY_EXIT = 2109
Global Const MQRC_FORMAT_ERROR = 2110
Global Const MQRC_SOURCE_CCSID_ERROR = 2111
Global Const MQRC_SOURCE_INTEGER_ENC_ERROR = 2112
Global Const MQRC_SOURCE_DECIMAL_ENC_ERROR = 2113
Global Const MQRC_SOURCE_FLOAT_ENC_ERROR = 2114
Global Const MQRC_TARGET_CCSID_ERROR = 2115
Global Const MQRC_TARGET_INTEGER_ENC_ERROR = 2116
Global Const MQRC_TARGET_DECIMAL_ENC_ERROR = 2117
Global Const MQRC_TARGET_FLOAT_ENC_ERROR = 2118
Global Const MQRC_NOT_CONVERTED = 2119
Global Const MQRC_CONVERTED_MSG_TOO_BIG = 2120
Global Const MQRC_BRIDGE_STARTED = 2125
Global Const MQRC_BRIDGE_STOPPED = 2126
Global Const MQRC_ADAPTER_STORAGE_SHORTAGE = 2127
Global Const MQRC_ADAPTER_CONN_LOAD_ERROR = 2129
Global Const MQRC_ADAPTER_SERV_LOAD_ERROR = 2130
Global Const MQRC_ADAPTER_DEFS_ERROR = 2131
Global Const MQRC_ADAPTER_DEFS_LOAD_ERROR = 2132
Global Const MQRC_ADAPTER_CONV_LOAD_ERROR = 2133
Global Const MQRC_ADAPTER_DISC_LOAD_ERROR = 2138
Global Const MQRC_CICS_WAIT_FAILED = 2140
Global Const MQRC_SOURCE_LENGTH_ERROR = 2143
Global Const MQRC_TARGET_LENGTH_ERROR = 2144
Global Const MQRC_SOURCE_BUFFER_ERROR = 2145
Global Const MQRC_TARGET_BUFFER_ERROR = 2146
Global Const MQRC_DBCS_ERROR = 2150
Global Const MQRC_TRUNCATED = 2151
Global Const MQRC_ASID_MISMATCH = 2157
Global Const MQRC_CONN_ID_IN_USE = 2160
Global Const MQRC_Q_MGR_QUIESCING = 2161
Global Const MQRC_Q_MGR_STOPPING = 2162
Global Const MQRC_DUPLICATE_RECOV_COORD = 2163
Global Const MQRC_PMO_ERROR = 2173
Global Const MQRC_API_EXIT_NOT_FOUND = 2182
Global Const MQRC_API_EXIT_LOAD_ERROR = 2183
Global Const MQRC_REMOTE_Q_NAME_ERROR = 2184
Global Const MQRC_GMO_ERROR = 2186
Global Const MQRC_PAGESET_FULL = 2192
Global Const MQRC_PAGESET_ERROR = 2193
Global Const MQRC_NAME_NOT_VALID_FOR_TYPE = 2194
Global Const MQRC_UNEXPECTED_ERROR = 2195
Global Const MQRC_UNKNOWN_XMIT_Q = 2196
Global Const MQRC_UNKNOWN_DEF_XMIT_Q = 2197
Global Const MQRC_DEF_XMIT_Q_TYPE_ERROR = 2198
Global Const MQRC_DEF_XMIT_Q_USAGE_ERROR = 2199
Global Const MQRC_NAME_IN_USE = 2201
Global Const MQRC_CONNECTION_QUIESCING = 2202
Global Const MQRC_CONNECTION_STOPPING = 2203
Global Const MQRC_ADAPTER_NOT_AVAILABLE = 2204
Global Const MQRC_MSG_ID_ERROR = 2206
Global Const MQRC_CORREL_ID_ERROR = 2207
Global Const MQRC_FILE_SYSTEM_ERROR = 2208
Global Const MQRC_NO_MSG_LOCKED = 2209
Global Const MQRC_FILE_NOT_AUDITED = 2216
Global Const MQRC_CONNECTION_NOT_AUTHORIZED = 2217
Global Const MQRC_MSG_TOO_BIG_FOR_CHANNEL = 2218
Global Const MQRC_CALL_IN_PROGRESS = 2219
Global Const MQRC_Q_MGR_ACTIVE = 2222
Global Const MQRC_Q_MGR_NOT_ACTIVE = 2223
Global Const MQRC_Q_DEPTH_HIGH = 2224
Global Const MQRC_Q_DEPTH_LOW = 2225
Global Const MQRC_Q_SERVICE_INTERVAL_HIGH = 2226
Global Const MQRC_Q_SERVICE_INTERVAL_OK = 2227
Global Const MQRC_HCONFIG_ERROR = 2280
Global Const MQRC_FUNCTION_ERROR = 2281
Global Const MQRC_CHANNEL_STARTED = 2282
Global Const MQRC_CHANNEL_STOPPED = 2283
Global Const MQRC_CHANNEL_CONV_ERROR = 2284
Global Const MQRC_SERVICE_NOT_AVAILABLE = 2285
Global Const MQRC_INITIALIZATION_FAILED = 2286
Global Const MQRC_TERMINATION_FAILED = 2287
Global Const MQRC_UNKNOWN_Q_NAME = 2288
Global Const MQRC_SERVICE_ERROR = 2289
Global Const MQRC_Q_ALREADY_EXISTS = 2290
Global Const MQRC_USER_ID_NOT_AVAILABLE = 2291
Global Const MQRC_UNKNOWN_ENTITY = 2292
Global Const MQRC_UNKNOWN_AUTH_ENTITY = 2293
Global Const MQRC_UNKNOWN_REF_OBJECT = 2294
Global Const MQRC_CHANNEL_ACTIVATED = 2295
Global Const MQRC_CHANNEL_NOT_ACTIVATED = 2296


'**********************************************************************'
'*  Values Related to Queue Attributes                                *'
'**********************************************************************'

'Queue Types'
Global Const MQQT_LOCAL = 1
Global Const MQQT_MODEL = 2
Global Const MQQT_ALIAS = 3
Global Const MQQT_REMOTE = 6

'Extended Queue Types'
Global Const MQQT_ALL = 1001

'Queue Definition Types'
Global Const MQQDT_PREDEFINED = 1
Global Const MQQDT_PERMANENT_DYNAMIC = 2
Global Const MQQDT_TEMPORARY_DYNAMIC = 3

'Inhibit Get'
Global Const MQQA_GET_INHIBITED = 1
Global Const MQQA_GET_ALLOWED = 0

'Inhibit Put'
Global Const MQQA_PUT_INHIBITED = 1
Global Const MQQA_PUT_ALLOWED = 0

'Queue Shareability'
Global Const MQQA_SHAREABLE = 1
Global Const MQQA_NOT_SHAREABLE = 0

'Back-Out Hardening'
Global Const MQQA_BACKOUT_HARDENED = 1
Global Const MQQA_BACKOUT_NOT_HARDENED = 0

'Message Delivery Sequence'
Global Const MQMDS_PRIORITY = 0
Global Const MQMDS_FIFO = 1

'Trigger Control'
Global Const MQTC_OFF = 0
Global Const MQTC_ON = 1

'Trigger Types'
Global Const MQTT_NONE = 0
Global Const MQTT_FIRST = 1
Global Const MQTT_EVERY = 2
Global Const MQTT_DEPTH = 3

'Queue Usage'
Global Const MQUS_NORMAL = 0
Global Const MQUS_TRANSMISSION = 1


'**********************************************************************'
'*  Values Related to Process-Definition Attributes                   *'
'**********************************************************************'

'Application Types'
'See values for "Put Application Types" above'


'**********************************************************************'
'*  Values Related to Queue-Manager Attributes                        *'
'**********************************************************************'

'Command Level'
Global Const MQCMDL_LEVEL_1 = 100
Global Const MQCMDL_LEVEL_114 = 114
Global Const MQCMDL_LEVEL_200 = 200
Global Const MQCMDL_LEVEL_201 = 201
Global Const MQCMDL_LEVEL_221 = 221
Global Const MQCMDL_LEVEL_320 = 320

'Platform'
Global Const MQPL_MVS = 1
Global Const MQPL_OS2 = 2
Global Const MQPL_AIX = 3
Global Const MQPL_UNIX = 3
Global Const MQPL_OS400 = 4
Global Const MQPL_WINDOWS = 5

'Syncpoint Availability'
Global Const MQSP_AVAILABLE = 1
Global Const MQSP_NOT_AVAILABLE = 0

'**********************************************************************'
'*  MQDLH Structure -- Dead Letter Header                             *'
'**********************************************************************'

Type MQDLH
  StrucId        As String * 4 'Structure identifier'
  Version        As Long      'Structure version number'
  Reason         As Long      'Reason message arrived on dead-letter'
                              '(undelivered-message) queue'
  DestQName      As String * 48 'Name of original destination queue'
  DestQMgrName   As String * 48 'Name of original destination queue manager'
  Encoding       As Long      'Original data encoding'
  CodedCharSetId As Long      'Original coded character set identifier'
  Format         As String * 8 'Original format name'
  PutApplType    As Long      'Type of application that put message on'
                              'dead-letter (undelivered-message) queue'
  PutApplName    As String * 28 'Name of application that put message on'
                              'dead-letter (undelivered-message) queue'
  PutDate        As String * 8 'Date when message was put on dead-letter'
                              '(undelivered-message) queue'
  PutTime        As String * 8 'Time when message was put on the dead-letter'
                              '(undelivered-message) queue'
End Type

Global MQDLH_DEFAULT As MQDLH

'**********************************************************************'
'*  MQGMO Structure -- Get Message Options                            *'
'**********************************************************************'

Type MQGMO
  StrucId       As String * 4 'Structure identifier'
  Version       As Long      'Structure version number'
  Options       As Long      'Options that control the action of MQGET'
  WaitInterval  As Long      'Wait interval'
  Signal1       As Long      'Signal'
  Signal2       As Long      'Reserved'
  ResolvedQName As String * 48 'Resolved name of destination queue'
End Type

Global MQGMO_DEFAULT As MQGMO
'**********************************************************************'
'* Registry key.                                                      *'
'* Fikile added this here 2008-04-21...                               *'
'**********************************************************************'
Global Const csReg_RequestKey = "Software\Mindkey\KeyTax\MQSettings\Send"
'**********************************************************************'
'*  MQMD Structure -- Message Descriptor                              *'
'**********************************************************************'

Type MQMD
  StrucId             As String * 4 'Structure identifier'
  Version             As Long      'Structure version number'
  Report              As Long      'Report options'
  MsgType             As Long      'Message type'
  Expiry              As Long      'Expiry time'
  Feedback            As Long      'Feedback or reason code'
  Encoding            As Long      'Data encoding'
  CodedCharSetId      As Long      'Coded character set identifier'
  Format              As String * 8 'Format name'
  Priority            As Long      'Message priority'
  Persistence         As Long      'Message persistence'
  MsgID               As String * 24 'Message identifier'
  CorrelID            As String * 24 'Correlation identifier'
  BackoutCount        As Long      'Backout counter'
  ReplyToQ            As String * 48 'Name of reply-to queue'
  ReplyToQMgr         As String * 48 'Name of reply queue manager'
  UserIdentifier      As String * 12 'User identifier'
  AccountingToken     As String * 32 'Accounting token'
  ApplIdentityData    As String * 32 'Application data relating to identity'
  PutApplType         As Long      'Type of application that put the message'
  PutApplName         As String * 28 'Name of application that put the message'
  PutDate             As String * 8 'Date when message was put'
  PutTime             As String * 8 'Time when message was put'
  ApplOriginData      As String * 4 'Application data relating to origin'
End Type

Global MQMD_DEFAULT As MQMD

'**********************************************************************'
'*  MQOD Structure -- Object Descriptor                               *'
'**********************************************************************'

Type MQOD
  StrucId         As String * 4 'Structure identifier'
  Version         As Long      'Structure version number'
  ObjectType      As Long      'Object type'
  ObjectName      As String * 48 'Object name'
  ObjectQMgrName  As String * 48 'Object queue manager name'
  DynamicQName    As String * 48 'Dynamic queue name'
  AlternateUserId As String * 12 'Alternate user identifier'
End Type

Global MQOD_DEFAULT As MQOD

'**********************************************************************'
'*  MQPMO Structure -- Put Message Options                            *'
'**********************************************************************'

Type MQPMO
  StrucId          As String * 4 'Structure identifier'
  Version          As Long      'Structure version number'
  Options          As Long      'Options that control the action of MQPUT or'
                                'MQPUT1'
  Timeout          As Long      'Reserved'
  Context          As Long      'Object handle of input queue'
  KnownDestCount   As Long      'Reserved'
  UnknownDestCount As Long      'Reserved'
  InvalidDestCount As Long      'Reserved'
  ResolvedQName    As String * 48 'Resolved name of destination queue'
  ResolvedQMgrName As String * 48 'Resolved name of destination queue manager'
End Type

Global MQPMO_DEFAULT As MQPMO

'**********************************************************************'
'*  MQTM Structure -- Trigger Message                                 *'
'**********************************************************************'

Type MQTM
  StrucId     As String * 4 'Structure identifier'
  Version     As Long       'Structure version number'
  QName       As String * 48 'Name of triggered queue'
  ProcessName As String * 48 'Name of process object'
  TriggerData As String * 64 'Trigger data'
  ApplType    As Long       'Application type'
  ApplId      As String * 256 'Application identifier'
  EnvData     As String * 128 'Environment data'
  UserData    As String * 128 'User data'
End Type

Global MQTM_DEFAULT As MQTM

'**********************************************************************'
'*  MQTMC2 Structure -- Trigger Message 2 (Character)                 *'
'**********************************************************************'

Type MQTMC2
  StrucId     As String * 4 'Structure identifier'
  Version     As String * 4 'Structure version number'
  QName       As String * 48 'Name of triggered queue'
  ProcessName As String * 48 'Name of process object'
  TriggerData As String * 64 'Trigger data'
  ApplType    As String * 4 'Application type'
  ApplId      As String * 256 'Application identifier'
  EnvData     As String * 128 'Environment data'
  UserData    As String * 128 'User data'
  QMgrName    As String * 48 'Queue manager name'
End Type

Global MQTMC2_DEFAULT As MQTMC2

'**********************************************************************'
'*  MQXQH Structure -- Transmission Queue Header                      *'
'**********************************************************************'

Type MQXQH
  StrucId        As String * 4 'Structure identifier'
  Version        As Long      'Structure version number'
  RemoteQName    As String * 48 'Name of destination queue'
  RemoteQMgrName As String * 48 'Name of destination queue manager'
  msgDesc        As MQMD      'Original message descriptor'
End Type

Global MQXQH_DEFAULT As MQXQH

'Visual Basic Dynamic Link Library Names'

  Global Const MQVBDLL = "MQICSTD.DLL" '"q:\mqm\bin\MQICSTD.DLL"
    
  ' Standard MQ functions called directly from user's application
  Declare Sub MQBACK Lib "MQICSTD.DLL" (ByVal Hconn As Long, CompCode As Long, Reason As Long)
  Declare Sub mqClose Lib "MQICSTD.DLL" Alias "MQCLOSE" (ByVal Hconn As Long, Hobj As Long, ByVal Options As Long, CompCode As Long, Reason As Long)
  Declare Sub MQCMIT Lib "MQICSTD.DLL" (ByVal Hconn As Long, CompCode As Long, Reason As Long)
  Declare Sub MQCONN Lib "MQICSTD.DLL" (ByVal QMgrName As String, Hconn As Long, CompCode As Long, Reason As Long)
  Declare Sub MQDISC Lib "MQICSTD.DLL" (Hconn As Long, CompCode As Long, Reason As Long)
  Declare Sub mqOpen Lib "MQICSTD.DLL" Alias "MQOPEN" (ByVal Hconn As Long, ObjDesc As MQOD, ByVal Options As Long, Hobj As Long, CompCode As Long, Reason As Long)
    
  ' Alternative form of MQ functions called directly from user's application
  Declare Sub MQGETAny Lib "MQICSTD.DLL" Alias "MQGET" (ByVal Hconn As Long, ByVal Hobj As Long, msgDesc As MQMD, getMsgOpts As MQGMO, ByVal BufferLength As Long, buffer As Any, DataLength As Long, CompCode As Long, Reason As Long)
  Declare Sub MQPUTAny Lib "MQICSTD.DLL" Alias "MQPUT" (ByVal Hconn As Long, ByVal Hobj As Long, msgDesc As MQMD, putMsgOpts As MQPMO, ByVal BufferLength As Long, buffer As Any, CompCode As Long, Reason As Long)
  Declare Sub MQPUT1Any Lib "MQICSTD.DLL" Alias "MQPUT1" (ByVal Hconn As Long, ObjDesc As MQOD, msgDesc As MQMD, putMsgOpts As MQPMO, ByVal BufferLength As Long, buffer As Any, CompCode As Long, Reason As Long)
    
  ' private functions accessed via "safe" versions such as MQGET
  Private Declare Sub MQINQX Lib "MQICSTD.DLL" Alias "MQINQ" (ByVal Hconn As Long, ByVal Hobj As Long, ByVal SelectorCount As Long, Selectors As Long, ByVal intAttrCount As Long, intAttrs As Long, ByVal CharAttrLength As Long, ByVal CharAttrs As String, CompCode As Long, Reason As Long)
  Private Declare Sub MQGETX Lib "MQICSTD.DLL" Alias "MQGET" (ByVal Hconn As Long, ByVal Hobj As Long, msgDesc As MQMD, getMsgOpts As MQGMO, ByVal BufferLength As Long, ByVal buffer As String, DataLength As Long, CompCode As Long, Reason As Long)
  Private Declare Sub MQPUTX Lib "MQICSTD.DLL" Alias "MQPUT" (ByVal Hconn As Long, ByVal Hobj As Long, msgDesc As MQMD, putMsgOpts As MQPMO, ByVal BufferLength As Long, ByVal buffer As String, CompCode As Long, Reason As Long)
  Private Declare Sub MQPUT1X Lib "MQICSTD.DLL" Alias "MQPUT1" (ByVal Hconn As Long, ObjDesc As MQOD, msgDesc As MQMD, putMsgOpts As MQPMO, ByVal BufferLength As Long, ByVal buffer As String, CompCode As Long, Reason As Long)
  Private Declare Sub MQSETX Lib "MQICSTD.DLL" Alias "MQSET" (ByVal Hconn As Long, ByVal Hobj As Long, ByVal SelectorCount As Long, Selectors As Long, ByVal intAttrCount As Long, intAttrs As Long, ByVal CharAttrLength As Long, ByVal CharAttrs As String, CompCode As Long, Reason As Long)


'**********************************************************************'
'*  MQDLH_DEFAULTS Subroutine -- Initialise MQDLH to default values   *'
'**********************************************************************'
Sub MQDLH_DEFAULTS(Struc As MQDLH)
  Struc.StrucId = MQDLH_STRUC_ID
  Struc.Version = MQDLH_VERSION_1
  Struc.Reason = MQRC_NONE
  Struc.DestQName = ""
  Struc.DestQMgrName = ""
  Struc.Encoding = 0
  Struc.CodedCharSetId = 0
  Struc.Format = MQFMT_NONE
  Struc.PutApplType = 0
  Struc.PutApplName = ""
  Struc.PutDate = ""
  Struc.PutTime = ""
End Sub

Sub MQGET(Hconn As Long, Hobj As Long, msgDesc As MQMD, getMsgOpts As MQGMO, BufferLength As Long, buffer As String, DataLength As Long, CompCode As Long, Reason As Long)
  If BufferLength > LenB(buffer) Then
    CompCode = MQCC_FAILED
    Reason = MQRC_BUFFER_LENGTH_ERROR
  Else
    MQGETX Hconn, Hobj, msgDesc, getMsgOpts, BufferLength, buffer, DataLength, CompCode, Reason
    Debug.Print "Put date & Time  :" & msgDesc.PutDate & " " & msgDesc.PutTime
    Debug.Print "MSGID :" & msgDesc.MsgID
    Debug.Print "CorrelID :" & msgDesc.CorrelID
    
    Debug.Print "Data :" & RTrim(buffer)
  End If
End Sub

'**********************************************************************'
'*  MQGMO_DEFAULTS Subroutine -- Initialise MQGMO to default values   *'
'**********************************************************************'
Sub MQGMO_DEFAULTS(Struc As MQGMO)
  Struc.StrucId = MQGMO_STRUC_ID
  Struc.Version = MQGMO_VERSION_1
  Struc.Options = MQGMO_NO_WAIT
  Struc.WaitInterval = 0
  Struc.Signal1 = 0
  Struc.Signal2 = 0
  Struc.ResolvedQName = ""
End Sub

Sub MQINQ(Hconn As Long, Hobj As Long, SelectorCount As Long, Selectors As Long, intAttrCount As Long, intAttrs As Long, CharAttrLength As Long, CharAttrs As String, CompCode As Long, Reason As Long)
  If CharAttrLength > LenB(CharAttrs) Then
    CompCode = MQCC_FAILED
    Reason = MQRC_BUFFER_LENGTH_ERROR
  Else
    MQINQX Hconn, Hobj, SelectorCount, Selectors, intAttrCount, intAttrs, CharAttrLength, CharAttrs, CompCode, Reason
  End If
End Sub

'**********************************************************************'
'*  MQMD_DEFAULTS Subroutine -- Initialise MQMD to default values     *'
'**********************************************************************'
Sub MQMD_DEFAULTS(Struc As MQMD)
  Struc.StrucId = MQMD_STRUC_ID
  Struc.Version = MQMD_VERSION_1
  Struc.Report = MQRO_NONE
  Struc.MsgType = MQMT_DATAGRAM
  Struc.Expiry = MQEI_UNLIMITED
  Struc.Feedback = MQFB_NONE
  Struc.Encoding = MQENC_NATIVE
  Struc.CodedCharSetId = MQCCSI_Q_MGR
  Struc.Format = MQFMT_NONE
  Struc.Priority = MQPRI_PRIORITY_AS_Q_DEF
  Struc.Persistence = MQPER_PERSISTENCE_AS_Q_DEF
   
  Struc.MsgID = String(24, 0)
  Struc.CorrelID = String(24, 0)
  
  Struc.BackoutCount = 0
  Struc.ReplyToQ = ""
  Struc.ReplyToQMgr = ""
  Struc.UserIdentifier = ""
  Struc.AccountingToken = String(32, 0)
  Struc.ApplIdentityData = ""
  Struc.PutApplType = MQAT_NO_CONTEXT
  Struc.PutApplName = ""
  Struc.PutDate = ""
  Struc.PutTime = ""
  Struc.ApplOriginData = ""
End Sub

'**********************************************************************'
'*  MQOD_DEFAULTS Subroutine -- Initialise MQOD to default values     *'
'**********************************************************************'
Sub MQOD_DEFAULTS(Struc As MQOD)
  Struc.StrucId = MQOD_STRUC_ID
  Struc.Version = MQOD_VERSION_1
  Struc.ObjectType = MQOT_Q
  Struc.ObjectName = ""
  Struc.ObjectQMgrName = ""
  Struc.DynamicQName = "AMQ.*"
  Struc.AlternateUserId = ""
End Sub

'**********************************************************************'
'*  MQPMO_DEFAULTS Subroutine -- Initialise MQPMO to default values   *'
'**********************************************************************'
Sub MQPMO_DEFAULTS(Struc As MQPMO)
  Struc.StrucId = MQPMO_STRUC_ID
  Struc.Version = MQPMO_VERSION_1
  Struc.Options = MQPMO_NONE
  Struc.Timeout = -1
  Struc.Context = 0
  Struc.KnownDestCount = 0
  Struc.UnknownDestCount = 0
  Struc.InvalidDestCount = 0
  Struc.ResolvedQName = ""
  Struc.ResolvedQMgrName = ""
End Sub

Sub MQPUT(Hconn As Long, Hobj As Long, msgDesc As MQMD, putMsgOpts As MQPMO, BufferLength As Long, buffer As String, CompCode As Long, Reason As Long)
  If BufferLength > LenB(buffer) Then
    CompCode = MQCC_FAILED
    Reason = MQRC_BUFFER_LENGTH_ERROR
  Else
    MQPUTX Hconn, Hobj, msgDesc, putMsgOpts, BufferLength, buffer, CompCode, Reason
  End If
End Sub

Sub MQPUT1(Hconn As Long, ObjDesc As MQOD, msgDesc As MQMD, putMsgOpts As MQPMO, BufferLength As Long, buffer As String, CompCode As Long, Reason As Long)
  If BufferLength > LenB(buffer) Then
    CompCode = MQCC_FAILED
    Reason = MQRC_BUFFER_LENGTH_ERROR
  Else
    MQPUT1X Hconn, ObjDesc, msgDesc, putMsgOpts, BufferLength, buffer, CompCode, Reason
  End If
End Sub

Sub MQSET(Hconn As Long, Hobj As Long, SelectorCount As Long, Selectors As Long, intAttrCount As Long, intAttrs As Long, CharAttrLength As Long, CharAttrs As String, CompCode As Long, Reason As Long)
  If CharAttrLength > LenB(CharAttrs) Then
    CompCode = MQCC_FAILED
    Reason = MQRC_BUFFER_LENGTH_ERROR
  Else
    MQSETX Hconn, Hobj, SelectorCount, Selectors, intAttrCount, intAttrs, CharAttrLength, CharAttrs, CompCode, Reason
  End If
End Sub

'**********************************************************************'
'*  MQTM_DEFAULTS Subroutine -- Initialise MQTM to default values     *'
'**********************************************************************'
Sub MQTM_DEFAULTS(Struc As MQTM)
  Struc.StrucId = MQTM_STRUC_ID
  Struc.Version = MQTM_VERSION_1
  Struc.QName = ""
  Struc.ProcessName = ""
  Struc.TriggerData = ""
  Struc.ApplType = 0
  Struc.ApplId = ""
  Struc.EnvData = ""
  Struc.UserData = ""
End Sub

'**********************************************************************'
'*  MQTMC2_DEFAULTS Subroutine -- Initialise MQTMC2 to default values *'
'**********************************************************************'
Sub MQTMC2_DEFAULTS(Struc As MQTMC2)
  Struc.StrucId = MQTMC_STRUC_ID
  Struc.Version = MQTMC_VERSION_2
  Struc.QName = ""
  Struc.ProcessName = ""
  Struc.TriggerData = ""
  Struc.ApplType = ""
  Struc.ApplId = ""
  Struc.EnvData = ""
  Struc.UserData = ""
  Struc.QMgrName = ""
End Sub

'**********************************************************************'
'*  MQXQH_DEFAULTS Subroutine -- Initialise MQXQH to default values   *'
'**********************************************************************'
Sub MQXQH_DEFAULTS(Struc As MQXQH)
  Struc.StrucId = MQXQH_STRUC_ID
  Struc.Version = MQXQH_VERSION_1
  Struc.RemoteQName = ""
  Struc.RemoteQMgrName = ""
  'MQMD_DEFAULTS (Struc.MsgDesc)
  Dim md As MQMD
  MQMD_DEFAULTS md
  Struc.msgDesc = md
End Sub

'**********************************************************************'
'*  MQ_SETDEFAULTS Subroutine -- Initialise default structures        *'
'**********************************************************************'
Sub MQ_SETDEFAULTS()
  MQDLH_DEFAULTS MQDLH_DEFAULT
  MQGMO_DEFAULTS MQGMO_DEFAULT
  MQMD_DEFAULTS MQMD_DEFAULT
  MQOD_DEFAULTS MQOD_DEFAULT
  MQPMO_DEFAULTS MQPMO_DEFAULT
  MQTM_DEFAULTS MQTM_DEFAULT
  MQTMC2_DEFAULTS MQTMC2_DEFAULT
  MQXQH_DEFAULTS MQXQH_DEFAULT
  
  MQMI_NONE = String(24, Chr$(0))
  MQCI_NONE = String(24, Chr$(0))
  MQACT_NONE = String(32, Chr$(0))
End Sub


Public Function GetMQErrDesc(ErrorCode As Long) As String
    Dim ReturnValue As String
    
    Select Case ErrorCode
        Case 0
          ReturnValue = "No reason to report"
        Case 2001
          ReturnValue = "Alias base queue not a valid type"
        Case 2002
          ReturnValue = "Application already connected"
        Case 2003
          ReturnValue = "Unit of work backed out"
        Case 2289
          ReturnValue = "Unexpected error occurred accessing service"
        Case 2290
          ReturnValue = "Queue object already exists"
        Case 2291
          ReturnValue = "Unable to determine the user ID"
        Case 2292
          ReturnValue = "Entity unknown to service"
        Case 2293
          ReturnValue = "Authorisation entity unknown to service"
        Case 2294
          ReturnValue = "Reference object unknown"
        Case 2295
          ReturnValue = "Channel activated"
        Case 2296
          ReturnValue = "Channel cannot be activated"
        Case 2004
          ReturnValue = "Buffer parameter not valid"
        Case 2005
          ReturnValue = "Buffer length parameter not valid"
        Case 2006
          ReturnValue = "Length of character attributes not valid"
        Case 2007
          ReturnValue = "Character attributes string not valid"
        Case 2008
          ReturnValue = "Not enough space allowed for character attributes"
        Case 2009
          ReturnValue = "Connection to queue manager lost"
        Case 2010
          ReturnValue = "Data length parameter not valid"
        Case 2011
          ReturnValue = "Name of dynamic queue not valid"
        Case 2012
          ReturnValue = "Call not valid in environment"
        Case 2013
          ReturnValue = "Expiry time not valid"
        Case 2014
          ReturnValue = "Feedback code not valid"
        Case 2016
          ReturnValue = "Gets inhibited for the queue"
        Case 2017
          ReturnValue = "No more handles available"
        Case 2018
          ReturnValue = "Connection handle not valid"
        Case 2019
          ReturnValue = "Object handle not valid"
        Case 2020
          ReturnValue = "Value for inhibit-get or inhibit-put queue attribute not valid"
        Case 2021
          ReturnValue = "Count of integer attributes not valid"
        Case 2022
          ReturnValue = "Not enough space allowed for integer attributes"
        Case 2023
          ReturnValue = "Integer attributes array not valid"
        Case 2024
          ReturnValue = "No more messages can be handled within current unit of work"
        Case 2025
          ReturnValue = "Maximum number of connections reached"
        Case 2026
          ReturnValue = "Message description not valid"
        Case 2027
          ReturnValue = "Missing reply-to queue"
        Case 2029
          ReturnValue = "Message type in message descriptor not valid"
        Case 2030
          ReturnValue = "Message length greater than maximum for queue"
        Case 2031
          ReturnValue = "Message length greater than maximum allowed by remote queue manager"
        Case 2033
          ReturnValue = "No message available"
        Case 2034
          ReturnValue = "Browse cursor not positioned on message"
        Case 2035
          ReturnValue = "Not authorised for access"
        Case 2036
          ReturnValue = "Queue not open for browse"
        Case 2037
          ReturnValue = "Queue not open for input"
        Case 2038
          ReturnValue = "Queue not open for inquire"
        Case 2040
          ReturnValue = "Queue not open for set"
        Case 2041
          ReturnValue = "Object definition changed since opened"
        Case 2042
          ReturnValue = "Object already open with conflicting options"
        Case 2043
          ReturnValue = "Object type not valid"
        Case 2044
          ReturnValue = "Object descriptor structure not valid"
        Case 2045
          ReturnValue = "Option not valid for object type"
        Case 2046
          ReturnValue = "Options not valid or not consistent"
        Case 2049
          ReturnValue = "Message priority exceeds maximum value supported"
        Case 2048
          ReturnValue = "Message on a temporary dynamic queue cannot be persistent"
        Case 2050
          ReturnValue = "Message priority not valid"
        Case 2051
          ReturnValue = "Put calls inhibited for the queue"
        Case 2052
          ReturnValue = "Queue has been deleted"
        Case 2053
          ReturnValue = "Queue already contains maximum number of messages"
        Case 2055
          ReturnValue = "Queue contains 1 or more messages or uncommitted put or get reqts"
        Case 2056
          ReturnValue = "No space available on disk for queue"
        Case 2057
          ReturnValue = "Queue type not valid"
        Case 2058
          ReturnValue = "Queue manager name not valid or not known"
        Case 2059
          ReturnValue = "Queue manager not available for connection"
        Case 2061
          ReturnValue = "Report options in message descriptor not valid"
        Case 2062
          ReturnValue = "A message is already marked"
        Case 2063
          ReturnValue = "Security error occurred"
        Case 2065
          ReturnValue = "Count of selectors not valid"
        Case 2066
          ReturnValue = "Count of selectors too big"
        Case 2067
          ReturnValue = "Attribute selector not valid"
        Case 2068
          ReturnValue = "Selector not applicable to queue type"
        Case 2069
          ReturnValue = "Signal outstanding for this handle"
        Case 2070
          ReturnValue = "No message returned (but signal request accepted)"
        Case 2071
          ReturnValue = "Insufficient storage available"
        Case 2072
          ReturnValue = "Syncpoint support not available"
        Case 2075
          ReturnValue = "Value for MQIA_TRIGGER_CONTROL attribute not valid"
        Case 2076
          ReturnValue = "Value for MQIA_TRIGGER_DEPTH attribute not valid"
        Case 2077
          ReturnValue = "Value for MQIA_TRIGGER_MSG_PRIORITY attribute not valid"
        Case 2078
          ReturnValue = "Value for MQIA_TRIGGER_TYPE attribute not valid"
        Case 2079
          ReturnValue = "Truncated message returned (processing completed)"
        Case 2080
          ReturnValue = "Truncated message control (processing not completed)"
        Case 2082
          ReturnValue = "Unknown alias base queue"
        Case 2085
          ReturnValue = "Unknown object name"
        Case 2086
          ReturnValue = "Unknown object queue manager"
        Case 2087
          ReturnValue = "Unknown remote queue manager"
        Case 2090
          ReturnValue = "Wait interval in MQGMO not valid"
        Case 2091
          ReturnValue = "Transmission queue not local"
        Case 2092
          ReturnValue = "Transmission queue with wrong usage"
        Case 2093
          ReturnValue = "Queue not open for pass all context"
        Case 2094
          ReturnValue = "Queue not open for pass identity context"
        Case 2095
          ReturnValue = "Queue not open for set all context"
        Case 2096
          ReturnValue = "Queue not open for set identity context"
        Case 2097
          ReturnValue = "Queue handle referred to does not save context"
        Case 2098
          ReturnValue = "Context not available for queue handle referred to"
        Case 2099
          ReturnValue = "Signal field not valid"
        Case 2100
          ReturnValue = "Object already exists"
        Case 2101
          ReturnValue = "Object damaged"
        Case 2102
          ReturnValue = "Insufficient system resources available"
        Case 2103
          ReturnValue = "Another queue manager already connected"
        Case 2104
          ReturnValue = "Report option(s) in message descriptor not recognised"
        Case 2105
          ReturnValue = "Storage class error"
        Case 2106
          ReturnValue = "COD report option not valid for XCF queue"
        Case 2107
          ReturnValue = "MQXWAIT call canceled"
        Case 2108
          ReturnValue = "Invocation of MQXWAIT call not valid"
        Case 2109
          ReturnValue = "Call suppressed by exit program"
        Case 2110
          ReturnValue = "Message format not valid"
        Case 2111
          ReturnValue = "Source coded character set identifier not valid"
        Case 2112
          ReturnValue = "Integer encoding in message not recognised"
        Case 2113
          ReturnValue = "Packed-decimal encoding in message not recognised"
        Case 2114
          ReturnValue = "Floating-point encoding in message not recognised"
        Case 2115
          ReturnValue = "Target coded character set identifier not valid"
        Case 2116
          ReturnValue = "Integer encoding specified by receiver not recognised"
        Case 2117
          ReturnValue = "Packed-decimal encoding specified by receiver not recognised"
        Case 2118
          ReturnValue = "Floating-point encoding specified by receiver not recognised"
        Case 2119
          ReturnValue = "Application message data not converted"
        Case 2120
          ReturnValue = "Converted message too big for application buffer"
        Case 2125
          ReturnValue = "Bridge started"
        Case 2126
          ReturnValue = "Bridge stopped"
        Case 2127
          ReturnValue = "Insufficient storage for adapter"
        Case 2129
          ReturnValue = "Unable to load adapter connection module"
        Case 2130
          ReturnValue = "Unable to load adapter service module"
        Case 2131
          ReturnValue = "Adapter subsystem definition module not valid"
        Case 2132
          ReturnValue = "Unable to load adapter subsystem definiton module"
        Case 2133
          ReturnValue = "Unable to load data conversion services modules"
        Case 2138
          ReturnValue = "Unable to load adapter disconnection module"
        Case 2140
          ReturnValue = "Wait request rejected by CICS"
        Case 2143
          ReturnValue = "Source length parameter not valid"
        Case 2144
          ReturnValue = "Target length parameter not valid"
        Case 2145
          ReturnValue = "Source buffer parameter not valid"
        Case 2146
          ReturnValue = "Target buffer parameter not valid"
        Case 2150
          ReturnValue = "DBCS string not valid"
        Case 2151
          ReturnValue = "Data truncated"
        Case 2157
          ReturnValue = "Primary and home ASIDs differ"
        Case 2160
          ReturnValue = "Connection identifier already in use"
        Case 2161
          ReturnValue = "Queue manager quiescing"
        Case 2162
          ReturnValue = "Queue manager shutting down"
        Case 2163
          ReturnValue = "Recovery coordinator already exists"
        Case 2173
          ReturnValue = "Put-message options structure not valid"
        Case 2183
          ReturnValue = "Unable to load API crossing exit"
        Case 2184
          ReturnValue = "Remote queue name not valid"
        Case 2186
          ReturnValue = "Get-message options structure not valid"
        Case 2192
          ReturnValue = "Page set data set full"
        Case 2193
          ReturnValue = "Error accessing page set data set"
        Case 2194
          ReturnValue = "Object name not valid for object type"
        Case 2195
          ReturnValue = "Unexpected error occurred"
        Case 2196
          ReturnValue = "Unknown transmission queue"
        Case 2197
          ReturnValue = "Unknown default transmission queue"
        Case 2198
          ReturnValue = "Default transmission queue not local"
        Case 2199
          ReturnValue = "Default transmission queue usage error"
        Case 2201
          ReturnValue = "Name in use"
        Case 2202
          ReturnValue = "Connection quiescing"
        Case 2203
          ReturnValue = "Connection shutting down"
        Case 2204
          ReturnValue = "Adapter not available"
        Case 2209
          ReturnValue = "No message locked"
        Case 2217
          ReturnValue = "Not authorised for connection"
        Case 2218
          ReturnValue = "Message length greater than maximum for channel"
        Case 2219
          ReturnValue = "MQ call reentered before previous call complete"
        Case 2222
          ReturnValue = "Queue manager created"
        Case 2223
          ReturnValue = "Queue manager unavailable"
        Case 2224
          ReturnValue = "Queue depth high limit reached or exceeded"
        Case 2225
          ReturnValue = "Queue depth low limit reached or exceeded"
        Case 2226
          ReturnValue = "Queue service interval high"
        Case 2227
          ReturnValue = "Queue service interval ok"
        Case 2280
          ReturnValue = "Configuration handle not valid"
        Case 2281
          ReturnValue = "Function identifier not valid for service"
        Case 2282
          ReturnValue = "Channel started"
        Case 2283
          ReturnValue = "Channel stopped"
        Case 2284
          ReturnValue = "Channel conversion error"
        Case 2285
          ReturnValue = "Underlying service not available"
        Case 2286
          ReturnValue = "Initialisation failed for an undefined reason"
        Case 2287
          ReturnValue = "Termination failed for an undefined reason"
        Case 2288
          ReturnValue = "Queue name not found"
        Case 2039
          ReturnValue = "Queue not open for output"
        Case 2047
          ReturnValue = "Persistence not valid"
    End Select
    
    GetMQErrDesc = ReturnValue
End Function
